package com.ruoyi.sl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sl.domain.SlOfcperformance;
import com.ruoyi.sl.service.ISlOfcperformanceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 绩效信息Controller
 * 
 * @author admin
 * @date 2024-06-14
 */
@RestController
@RequestMapping("/sl/ofcperformance")
public class SlOfcperformanceController extends BaseController
{
    @Autowired
    private ISlOfcperformanceService slOfcperformanceService;

    /**
     * 查询绩效信息列表
     */
    @PreAuthorize("@ss.hasPermi('sl:monthofc:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlOfcperformance slOfcperformance)
    {
        startPage();
        List<SlOfcperformance> list = slOfcperformanceService.selectSlOfcperformanceList(slOfcperformance);
        return getDataTable(list);
    }

    /**
     * 导出绩效信息列表
     */
    @PreAuthorize("@ss.hasPermi('sl:monthofc:export')")
    @Log(title = "绩效信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlOfcperformance slOfcperformance)
    {
        List<SlOfcperformance> list = slOfcperformanceService.selectSlOfcperformanceList(slOfcperformance);
        ExcelUtil<SlOfcperformance> util = new ExcelUtil<SlOfcperformance>(SlOfcperformance.class);
        util.exportExcel(response, list, "绩效信息数据");
    }

    /**
     * 获取绩效信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('sl:monthofc:query')")
    @GetMapping(value = "/{performanceId}")
    public AjaxResult getInfo(@PathVariable("performanceId") Long performanceId)
    {
        return success(slOfcperformanceService.selectSlOfcperformanceByPerformanceId(performanceId));
    }

    /**
     * 新增绩效信息
     */
    @PreAuthorize("@ss.hasPermi('sl:monthofc:add')")
    @Log(title = "绩效信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlOfcperformance slOfcperformance)
    {
        return toAjax(slOfcperformanceService.insertSlOfcperformance(slOfcperformance));
    }

    /**
     * 修改绩效信息
     */
    @PreAuthorize("@ss.hasPermi('sl:monthofc:edit')")
    @Log(title = "绩效信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlOfcperformance slOfcperformance)
    {
        return toAjax(slOfcperformanceService.updateSlOfcperformance(slOfcperformance));
    }

    /**
     * 删除绩效信息
     */
    @PreAuthorize("@ss.hasPermi('sl:monthofc:remove')")
    @Log(title = "绩效信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{performanceIds}")
    public AjaxResult remove(@PathVariable Long[] performanceIds)
    {
        return toAjax(slOfcperformanceService.deleteSlOfcperformanceByPerformanceIds(performanceIds));
    }
}
